package com.hello;

import java.util.Scanner;

public class 求平均分 {
    public static void main(String[] args) {
       int[] arr=getScore();
        int min=getMin(arr);
        int max=getMax(arr);
        int sum=getsum(arr);
        int avg=(sum-min-max)/(arr.length-2);
        System.out.println(avg);
    }

    public static int[] getScore() {
        Scanner sc = new Scanner(System.in);
        int[] scores = new int[6];
        for (int i = 0; i < 6;) {
            System.out.println("请输入评委的评分");
            int score = sc.nextInt();
            if(score>=0&&score<=100){
                scores[i] = score;
                i++;
            }else{
                System.out.println("成绩超出了范围，请重新录入");
            }
        }
        return scores;
    }
    public static int getMax(int arr[]){
        int max=arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(max>arr[i]){
                max=arr[i];
            }
        }
        return max;
    }
    public static int getMin(int arr[]){
        int min=arr[0];//批量修改Shift+Fn+F6
        for (int i = 1; i < arr.length; i++) {
            if(min>arr[i]){
                min=arr[i];
            }
        }
        return min;
    }
    public static int getsum(int[] arr){
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        return sum;
    }
}
